package training.framework.persistence;

import java.util.HashMap;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class CreateTables {
	public static void main(String[] args) {
		if (args.length != 1) {
			System.out.println("Please specify the persistence unit name");
		} else {
			Map<String, String> properties = new HashMap<String, String>();
			properties.put("hibernate.hbm2ddl.auto", "create");
			EntityManagerFactory factory = Persistence.createEntityManagerFactory(args[0], properties);
			EntityManager manager = factory.createEntityManager();
			manager.close();
			factory.close();			
		}
	}
}
